//
//  LXStatusOringinalView.swift
//  weibo
//
//  Created by 罗心 on 16/6/27.
//  Copyright © 2016年 罗心. All rights reserved.
//

import UIKit

class LXStatusOringinalView: UIView {
    
    var status:LXStatus? {
        didSet{
            nameLabel.text = status?.user?.name
            
        headImageView.sd_setImageWithURL(NSURL(string:status?.user?.profile_image_url ?? ""), placeholderImage: UIImage(named: "avatar_default_big"))
            contentLabel.text = status?.text
            vipImageView.image = status?.user?.verifiedImage
            expiredImageView.image = status?.user?.mbrankImage
        }
        
        
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    //设置UI
    private func setupUI() {
        addSubview(headImageView)
        addSubview(expiredImageView)
        addSubview(vipImageView)
        addSubview(nameLabel)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(contentLabel)
                
        //设置约束
        headImageView.snp_makeConstraints { (make) in
            make.top.leading.equalTo(self).offset(10)
            make.size.equalTo(CGSize(width: 35, height: 35))
        }
        
        nameLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headImageView)
            make.leading.equalTo(headImageView.snp_trailing).offset(10)
        }
        expiredImageView.snp_makeConstraints { (make) in
            make.top.equalTo(nameLabel)
            make.leading.equalTo(nameLabel.snp_trailing).offset(10)
        }
        vipImageView.snp_makeConstraints { (make) in
            make.centerX.equalTo(headImageView.snp_bottom)
            make.centerY.equalTo(headImageView.snp_trailing)
        }
        timeLabel.snp_makeConstraints { (make) in
            make.leading.equalTo(expiredImageView)
            make.bottom.equalTo(headImageView)
        }
        sourceLabel.snp_makeConstraints { (make) in
            make.leading.equalTo(timeLabel.snp_trailing).offset(10)
            make.bottom.equalTo(headImageView)
        }
        contentLabel.snp_makeConstraints { (make) in
            make.top.equalTo(headImageView.snp_bottom).offset(10)
            make.leading.equalTo(headImageView)
        }
        self.snp_makeConstraints { (make) in
            make.bottom.equalTo(contentLabel).offset(10)
        }
        
    }
    
    //懒加载控件
    private lazy var headImageView: UIImageView = UIImageView(image:UIImage(named:"avatar_default_big"))
    private lazy var expiredImageView: UIImageView = UIImageView(image:UIImage(named:"common_icon_membership_expired"))
    private lazy var vipImageView: UIImageView = UIImageView(image:UIImage(named:"avatar_vip"))
    private lazy var nameLabel: UILabel = UILabel(textColor: UIColor.darkGrayColor(), textFont: 15)
    private lazy var timeLabel: UILabel = UILabel(textColor: ThemeColor, textFont: 10)
    private lazy var sourceLabel: UILabel = UILabel(textColor: UIColor.grayColor(), textFont: 10)
    private lazy var contentLabel: UILabel = UILabel(textColor: UIColor.blackColor(), textFont: 15, maxWidth: ScreenW - 20)

}
